package com.javaxiaobang;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableEurekaClient //注册到eureka注册中心
@EnableCircuitBreaker //开启熔断器（EnableHystrix和EnableCircuitBreaker一样）
public class HystrixApplication {

    @Value("${eurekaserver.user}")
    private String username;

    @Value("${eurekaserver.password}")
    private String password;

    public static void main(String[] args) {
        int SHARED_SHIFT = 16;
        System.out.println(1 << 16);
//
//        ThreadLocalManager.reset();
//        SpringApplication.run(HystrixApplication.class, args);
    }

    @Bean
    @LoadBalanced
    public RestTemplate template() {
        RestTemplate restTemplate = new RestTemplate();
//        restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(username, password));//代码增加安全认证
        return restTemplate;
    }


}



